package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ProgressBar;

import androidx.appcompat.app.AppCompatActivity;

public class SecondActivity extends AppCompatActivity {
    private ProgressBar progressBar;
    private int count=0;

    @Override
    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.second);
        progressBar = (ProgressBar)findViewById(R.id.progressBar);

        //开启一条新的线程
        new Thread(new Runnable() {
            @Override
            public void run() {
                while(true)
                {
                    count++;
                    progressBar.setProgress(count);
                    try {
                        Thread.sleep(20);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    if(count>100){
                        break;
                    }
                }
            }
        }).start();
    }
}